package com.lilicould.controller;

import com.lilicould.entity.Account;
import com.lilicould.entity.Employee;
import com.lilicould.entity.EmployeeDetails;
import com.lilicould.service.impl.AccountServiceImpl;
import com.lilicould.service.impl.EmployeeServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/employee/info")
public class EmployeeInfoController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<EmployeeDetails> employeeDetails;
        EmployeeServiceImpl employeeService = new EmployeeServiceImpl();
        employeeDetails = employeeService.getAllEmployeeDetails();
        req.getSession().setAttribute("employeeDetails", employeeDetails);
        req.getRequestDispatcher("/admin.jsp").forward(req, resp);
    }
}
